/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//图片上传
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//图片上传

$(".fileupload").fileupload({
        url: '/member/index.php?c=uppic&act=ajaxvideoupload',
        dataType: 'json',
        add: function (e, data) {
            $('.up_progress .progress-bar').css('width', '0px');
            jQuery(this).parent().siblings('.up_progress').show();
            jQuery(this).parent().siblings('.up_progress').find(' .progress-bar').html('Uploading...');
            data.submit();
        },
        done: function (e, data) {
            var name = $(this).data('name');
            $('.up_progress').hide();
            $('.upl').remove();
            var d = data.result;
			console.log(d.url);
			console.log(d.s_thumb);
            if (d.url == 1) {
                alert(d.s_thumb);
            } else {
                var imgshow = '<div class="images_zone"><input type="hidden" name="'+name+'" value="' + d.url + '" /><span><embed src="' + d.url + '" autostart="true" loop="true" width="380" height="214"></embed></span></div>';
                jQuery(this).parent().siblings('.files').html(imgshow);
            }
        },
		fail:function(e,data){
			var d = data.result;
			console.log(d.url);
			console.log(d.s_thumb);
			if (d.url == 1) {
				alert(d.s_thumb);
			}
		},
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 10);
            $('.up_progress .progress-bar').css('width', progress + '%');
			jQuery(this).parent().siblings('.up_progress').find(' .progress-bar').html(progress + '%');
        }
    });

//图片删除
$('.files').on({
    mouseenter: function () {
        $(this).find('.deldre_img').show();
    },
    mouseleave: function () {
        $(this).find('.deldre_img').hide();
    },
}, '.images_zone');
$('.files').on('click', '.deldre_img', function () {
    $(this).parent().remove();
});
